package etf.tests;

import etf.db40.BlobDb4o;
import etf.jdbc.BlobJDBC;

public class BlobTest extends Test{
	private BlobDb4o 			db4o;
	private BlobJDBC 			jdbc;
//	String[] inserts = {"100KB","100KB","500KB","1MB","2MB","5MB"};
	
	String[] inserts = {"2MB"};
	
	public BlobTest(){
		db4o = new BlobDb4o("blobTest");
		jdbc = new BlobJDBC();
	}
	
	public void testBlobInsert(){
		printSeparator(0);
		System.out.println("    TESTIRANJE UPISA I CITANJA BLOB OBJEKTA");
		for (int i = 0; i < inserts.length; i++){
			System.out.println("Insert slike velicine  " + inserts[i]);
			System.out.println("Db40           : " + db4o.insertBLOB(inserts[i]) + " ms");
			System.out.println("Db40           : " + db4o.insertBLOB2(inserts[i]) + " ms");
			System.out.println("JDBC/MySQL     : " + jdbc.insertBLOB(inserts[i]) + " ms");
		}
	}
	
	public void testBlobRead(){
		printSeparator(0);
		System.out.println("    TESTIRANJE CITANJA BLOB OBJEKTA");
		for (int i = 0; i < inserts.length; i++){
			System.out.println("Citanje slike velicine  " + inserts[i]);
			System.out.println("Db40           : " + db4o.readBLOB(inserts[i]) + " ms");
			System.out.println("Db40           : " + db4o.readBLOB2(inserts[i]) + " ms");
			System.out.println("JDBC/MySQL     : " + jdbc.readBLOB(inserts[i]) + " ms");
		}
	}
	
	public void closeSesions() {
		db4o.closeDatabase();
		jdbc.closeSession();
		
	}
}
